package com.qcq.wecheck.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author O
 * @since 2018-09-19
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class User extends Model<User> {

	private static final long serialVersionUID = 1L;

	/**
	 * 对应微信小程序的openId
	 */
	@TableId("open_id")
	@NotNull(message = "openId不能为空")
	private String openId;
	/**
	 * 名字
	 */
	@NotEmpty(message = "姓名不能为空")
	@Size(min = 2, max = 4, message = "姓名只能输入2-4位")
	@Excel(name = "姓名", orderNum = "0")
	private String name;
	/**
	 * 创建时间
	 */
	@TableField("create_time")
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
	private LocalDateTime createTime;
	/**
	 * 最近登陆时间
	 */
	@TableField("last_login_time")
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
	private LocalDateTime lastLoginTime;
	/**
	 * 微信昵称
	 */
	@TableField("nickname")
	@NotEmpty(message = "微信昵称不能为空")
	@Excel(name = "微信昵称", orderNum = "1")
	private String nickname;
	/**
	 * 微信头像url地址
	 */
	@NotEmpty(message = "微信头像url地址不能为空")
	@TableField("img_url")
	private String imgUrl;
	/**
	 * 联系电话
	 */
	@Excel(name = "联系电话", orderNum = "2")
	@TableField("tel")
	private String tel;

	/**
	* 备注信息
	*/
	@TableField("remark")
	@Excel(name = "备注", orderNum = "3")
	private String remark;

	@Override
	protected Serializable pkVal() {
		return this.openId;
	}

}
